home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / parsed / parse.frm < prev    next >
Text File  |  1995-05-02  |  10KB  |  359 lines

  1. VERSION 2.00
  2. Begin Form frmParse 
  3.    Caption         =   "Parse Demo Main Menu"
  4.    ClientHeight    =   5685
  5.    ClientLeft      =   75
  6.    ClientTop       =   645
  7.    ClientWidth     =   9450
  8.    Height          =   6375
  9.    Left            =   15
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5685
  12.    ScaleWidth      =   9450
  13.    Top             =   15
  14.    Width           =   9570
  15.    Begin SpinButton Spin1 
  16.       Delay           =   100
  17.       Enabled         =   0   'False
  18.       Height          =   345
  19.       Left            =   8385
  20.       Top             =   1635
  21.       Width           =   270
  22.    End
  23.    Begin CommandButton cmdMulti 
  24.       Caption         =   "&Multiple Char. Delim Test"
  25.       Height          =   360
  26.       Left            =   6135
  27.       TabIndex        =   10
  28.       Top             =   330
  29.       Width           =   2580
  30.    End
  31.    Begin OptionButton optParse 
  32.       Caption         =   "Pars&eAndFillArray2%()"
  33.       Height          =   270
  34.       Index           =   1
  35.       Left            =   525
  36.       TabIndex        =   1
  37.       Top             =   915
  38.       Width           =   4965
  39.    End
  40.    Begin OptionButton optParse 
  41.       Caption         =   "Pars&eAndFillArray1%()"
  42.       Height          =   270
  43.       Index           =   0
  44.       Left            =   525
  45.       TabIndex        =   0
  46.       Top             =   570
  47.       Value           =   -1  'True
  48.       Width           =   4965
  49.    End
  50.    Begin CommandButton cmdProcess 
  51.       Caption         =   "&Process Text"
  52.       Height          =   390
  53.       Left            =   6810
  54.       TabIndex        =   3
  55.       Top             =   2085
  56.       Width           =   1965
  57.    End
  58.    Begin TextBox txtFileContents 
  59.       Height          =   3060
  60.       Left            =   270
  61.       MultiLine       =   -1  'True
  62.       ScrollBars      =   3  'Both
  63.       TabIndex        =   4
  64.       Top             =   1995
  65.       Width           =   5910
  66.    End
  67.    Begin CommandButton cmdSelectFile 
  68.       Caption         =   "&Select File"
  69.       Height          =   345
  70.       Left            =   345
  71.       TabIndex        =   2
  72.       Top             =   1485
  73.       Width           =   1965
  74.    End
  75.    Begin Shape Shape3 
  76.       Height          =   1095
  77.       Left            =   5835
  78.       Shape           =   4  'Rounded Rectangle
  79.       Top             =   165
  80.       Width           =   3405
  81.    End
  82.    Begin Shape Shape2 
  83.       Height          =   4230
  84.       Left            =   105
  85.       Shape           =   4  'Rounded Rectangle
  86.       Top             =   1380
  87.       Width           =   9225
  88.    End
  89.    Begin Label lblReDimInt 
  90.       BorderStyle     =   1  'Fixed Single
  91.       Caption         =   "10"
  92.       ForeColor       =   &H00C0C0C0&
  93.       Height          =   285
  94.       Left            =   7830
  95.       TabIndex        =   14
  96.       Top             =   1635
  97.       Width           =   420
  98.    End
  99.    Begin Label Label2 
  100.       Caption         =   "ReDim Interval:"
  101.       ForeColor       =   &H00C0C0C0&
  102.       Height          =   270
  103.       Left            =   6315
  104.       TabIndex        =   13
  105.       Top             =   1635
  106.       Width           =   1425
  107.    End
  108.    Begin Label lblLineCountAdj 
  109.       BorderStyle     =   1  'Fixed Single
  110.       Height          =   795
  111.       Left            =   6495
  112.       TabIndex        =   12
  113.       Top             =   3345
  114.       Width           =   2655
  115.    End
  116.    Begin Label lblLineCount 
  117.       BorderStyle     =   1  'Fixed Single
  118.       Height          =   690
  119.       Left            =   6495
  120.       TabIndex        =   11
  121.       Top             =   2595
  122.       Width           =   2655
  123.    End
  124.    Begin Label lblWordCount 
  125.       BorderStyle     =   1  'Fixed Single
  126.       Height          =   330
  127.       Left            =   6495
  128.       TabIndex        =   9
  129.       Top             =   4215
  130.       Width           =   2655
  131.    End
  132.    Begin Label Label1 
  133.       Alignment       =   2  'Center
  134.       BorderStyle     =   1  'Fixed Single
  135.       Caption         =   "Select Function To Test:"
  136.       Height          =   270
  137.       Left            =   1590
  138.       TabIndex        =   8
  139.       Top             =   255
  140.       Width           =   2475
  141.    End
  142.    Begin Shape Shape1 
  143.       Height          =   1200
  144.       Left            =   420
  145.       Shape           =   4  'Rounded Rectangle
  146.       Top             =   150
  147.       Width           =   5160
  148.    End
  149.    Begin Label lblFileLen 
  150.       BorderStyle     =   1  'Fixed Single
  151.       Height          =   330
  152.       Left            =   360
  153.       TabIndex        =   7
  154.       Top             =   5145
  155.       Width           =   3090
  156.    End
  157.    Begin Label lblInfo 
  158.       BorderStyle     =   1  'Fixed Single
  159.       Height          =   750
  160.       Left            =   6495
  161.       TabIndex        =   6
  162.       Top             =   4605
  163.       Width           =   2655
  164.    End
  165.    Begin Label lblFileName 
  166.       BorderStyle     =   1  'Fixed Single
  167.       Height          =   300
  168.       Left            =   2610
  169.       TabIndex        =   5
  170.       Top             =   1530
  171.       Width           =   3435
  172.    End
  173.    Begin Menu mnuFile 
  174.       Caption         =   "&File"
  175.       Begin Menu mnuFileExit 
  176.          Caption         =   "E&xit"
  177.          Shortcut        =   ^X
  178.       End
  179.    End
  180.    Begin Menu mnuInfo 
  181.       Caption         =   "&Info!"
  182.    End
  183. End
  184. Option Explicit
  185.  
  186. Sub cmdMulti_Click ()
  187.    Screen.MousePointer = HOURGLASS
  188.    Load frmMultiDelim
  189.    
  190.    If optParse(0).Value = True Then
  191.       frmMultiDelim!lblCurRoutine = "ParseAndFillArray1%()"
  192.    Else
  193.       frmMultiDelim!lblCurRoutine = "ParseAndFillArray2%()"
  194.    End If
  195.    
  196.    frmMultiDelim.Show NORMAL
  197.    Me.WindowState = MINIMIZED
  198. End Sub
  199.  
  200. Sub cmdProcess_Click ()
  201.    Dim LineCount%, LineCountAdj%, WordCount%
  202.    Dim ret%, SetReDim%
  203.    Dim NewString$
  204.    Dim crlf$, SpaceChar$
  205.    Dim DynArray$()
  206.    Dim CurTime!, NewTime!, TotalTime!
  207.  
  208.    'set delimiters
  209.    crlf$ = Chr$(13) & Chr$(10)
  210.    SpaceChar$ = Chr$(32)
  211.  
  212.    'clear previous displayed info
  213.    lblLineCount = ""
  214.    lblLineCountAdj = ""
  215.    lblWordCount = ""
  216.    lblInfo = ""
  217.    'allow these labels to clear
  218.    DoEvents
  219.    
  220.    'NOTE: In a previous program
  221.    'I also tested QuickPak Professional parse routines
  222.    'and VideoSoft VSAWK (VSVBX). If
  223.    'you come up with a faster routine, just add it to
  224.    'this project and create another optParse radio button
  225.    'for it.
  226.  
  227.    Screen.MousePointer = HOURGLASS
  228.    
  229.    'call appropriate proc.
  230.    If optParse(0).Value = True Then
  231.    'use ParseAndFillArray1% function
  232.       CurTime! = Timer
  233.       LineCount% = ParseAndFillArray1%((txtFileContents), crlf$, DynArray$())
  234.       'build a new string with crlf's replaced by Chr$(32) 's
  235.       'LineCountAdj% passed byref. and filled with adjusted value for # lines
  236.       NewString$ = ProcessArray$(DynArray$(), Chr$(32), LineCountAdj%)
  237.       'erase array storage
  238.       Erase DynArray$
  239.       'get word count by passing processed string with all spaces
  240.       WordCount% = ParseAndFillArray1%(NewString$, SpaceChar$, DynArray$())
  241.       NewTime! = Timer
  242.       MsgBox "ParseAndFillArray1%() Completed.", MB_ICONINFORMATION
  243.    Else  'If optParse(1).Value = True
  244.       'get ReDim setting from user
  245.       'assign the Redim setting
  246.       SetReDim% = ret%
  247.       CurTime! = Timer
  248.       LineCount% = ParseAndFillArray2%((txtFileContents), crlf$, DynArray$(), CInt(lblReDimInt))
  249.       'build a new string with crlf's replaced by Chr$(32) 's
  250.       'LineCountAdj% passed byref. and filled with adjusted value for # lines
  251.       NewString$ = ProcessArray$(DynArray$(), Chr$(32), LineCountAdj%)
  252.       'erase array storage
  253.       Erase DynArray$
  254.       'get word count by passing processed string with all spaces
  255.       WordCount% = ParseAndFillArray2%(NewString$, SpaceChar$, DynArray$(), 10)
  256.       NewTime! = Timer
  257.       MsgBox "ParseAndFillArray2%() Completed.", MB_ICONINFORMATION
  258.    End If
  259.  
  260.    Screen.MousePointer = DEFAULT
  261.  
  262.    'display the info
  263.    'line count
  264.    lblLineCount = "Number of Lines (including extra CRLF pairs): " & CStr(LineCount%)
  265.    '